package com.zzvcom.office.exception;

import com.zzvcom.office.vo.ResultVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;


@ControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    @ExceptionHandler(OfficeConverterRunningException.class)
    @ResponseBody
    public ResultVo<Object> handleRunningException(Exception e) {
        log.error("转码提示", e);
        return ResultVo.warning("转码提示", e.getMessage());
    }

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public ResultVo<Object> handleAll(Exception e) {
        log.error("全局异常的捕获", e);
        return ResultVo.error("系统错误", e.getMessage());
    }
}


